#!/usr/bin/env python

from PIL import Image

im = Image.open('wire.png')
new_im = Image.new('RGB', (100, 100))

def put(x, y, i):
    new_im.putpixel((x, y), im.getpixel((i, 0)))

i = 0
for s in range(50):
    for x in range(s, 100 - s):
        put(x, s, i)
        i += 1
    for y in range(s + 1, 100 - s):
        put(100 - s - 1, y, i)
        i += 1
    for x in range(100 - s - 2, s - 1, -1):
        put(x, 100 - s - 1, i)
        i += 1
    for y in range(100 - s - 2, s, -1):
        put(s, y, i)
        i += 1
    
new_im.save('wire_res.png', 'PNG')
